<?php
/**
* @name Maiji
* @author pd87@qq.com
* @copyright m-j.cc
* @version v1.0
* 2018年3月30日 v1.0
* 2018年4月4日 v2.0
*/
namespace MAIJI;

use MAIJI\db\Connection;

class Model extends Connection
{
	
	public function __construct($bname = '',array $config = []){
		if(empty($bname)){
			$this -> table($this -> _table_());
		}else{
			$this -> table($bname);
		}
		parent::__construct($config);
	}
	
	/* 
		取当前模型名
	*/
	protected function _table_(){
		$name = str_replace('\\','/',get_called_class());
		$name = basename($name);
		$name = humpToLine($name);
		if(substr($name,0,1) == '_'){
			return substr($name,1);
		}else{
			return $name;
		}
	}
}